﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Streambolics.Gui
{
    /// <summary>
    ///     A standard dialog with OK and Cancel buttons.
    /// </summary>

    public partial class OkCancelDialog : OkDialog
    {
        public OkCancelDialog ()
        {
            InitializeComponent ();
        }

        /// <summary>
        ///     This is called after the user has cancelled the dialog.
        /// </summary>
        /// <remarks><para>
        ///     Throwing an exception here will not stop the cancelling process,
        ///     and the dialog will be closed anyway.
        ///     In order to intercept the cancel, use OnCancelling instead.
        /// </para><para>
        ///     The event will not be called when the user closes the dialog by clicking
        ///     on the close box.
        /// </para></remarks>
        /// <param name="e">
        /// </param>

        protected virtual void OnCancelled (EventArgs e)
        {
            // TODO : Call the Cancelled Event
        }

        /// <summary>
        ///     This is called when the user wants to cancel the dialog.
        /// </summary>
        /// <remarks><para>
        ///     Throwing an exception here will stop the cancelling process.
        ///     The dialog will stay displayed.
        /// </para></remarks>
        /// <param name="e">
        /// </param>

        protected virtual void OnCancelling (EventArgs e)
        {
            // TODO : Call the Cancelling Event
        }

        protected void DoCancel (EventArgs e)
        {
            OnCancelling (e);
            DialogResult = DialogResult.Cancel;
            OnCancelled (e);
        }

        protected void DoCancel ()
        {
            DoCancel (EventArgs.Empty);
        }

        private void button_Cancel_Click (object sender, EventArgs e)
        {
            DoCancel (e);
        }

    }
}
